/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import Message.Message;
import java.io.ObjectInputStream;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import mmt_client.MMT_CLIENT;

/**
 *
 * @author CUCAINHO
 */
 class  ReciveServer extends GUI_Main implements Runnable { 

        private Socket theclient;  
	private ObjectInputStream in;
	public ReciveServer (Socket theclient) { 
		this.theclient = theclient; 		
		Thread t = new Thread(this); 
		t.start(); 
	} 
	
	public void run() {
		while(true){
		try 
		{      
                        in = new ObjectInputStream(theclient.getInputStream());
                        Message ms = new Message();
                        try{
                             ms = (Message)in.readObject(); // doc message    
                        }
                        catch(Exception ex){
                            System.out.println("Loi khi doc message");
                        }

                        if(ms != null) {
                            try
                            {                                    
                                HandMessage(ms , theclient);				
                            }catch(Exception ex){
                                System.out.println("OUT!");
                            }  
			} 		
		} 
		catch (Exception e) { 

		} 
	}
        }
 }



